package com.woniuxy.mapper;

import java.sql.Date;
import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.woniuxy.pojo.DayMoney;
import com.woniuxy.pojo.MonthMoney;

public interface TurnoverMapper {
	//查询本月每天营业额

	@Select("SELECT DATE_FORMAT( ostart, '%Y-%m-%d' ) AS time, SUM(totalprice) AS total FROM `order`  WHERE  DATE_FORMAT(ostart,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m')  AND ostate in('已评价','已消费','已支付')  GROUP BY DATE_FORMAT( ostart, '%Y-%m-%d' )")
	public List<DayMoney> findDayMoney();
	//查询某月每天营业额
	@Select("select DATE_FORMAT( ostart, '%Y-%m-%d' ) AS time, SUM(totalprice) AS total from `order`   where date_format(ostart,'%Y-%m-%d') BETWEEN date_format(#{fristday},'%Y-%m-%d') AND date_format(#{lastday},'%Y-%m-%d') AND ostate in('已评价','已消费','已支付') GROUP BY DATE_FORMAT( ostart, '%Y-%m-%d' )")
	public List<DayMoney> findOneDayMoney(@Param("fristday")String fristday,@Param("lastday")String lastday );
	//查询某年每个月营业额
	@Select("select sum(totalprice) as month_money,date_format(ostart,'%m') as month_id from `order` where year(ostart)=#{year} group by month_id;")
	public List<MonthMoney> findMonthMoney(String year);
}
